package leecode

import (
	"fmt"
	"math"
)

func Reverse(x int) int {
	var result int
	for x != 0 {
		//首先判断x  是否在int32的范围之外
		if result > math.MaxInt32/10 || result < math.MinInt32/10 {
			return 0
		}
		fmt.Println(result, math.MaxInt32/10-1, result < math.MinInt32/10)
		count := x % 10 //count 用来记录每一位的数字
		x = x / 10
		result = result*10 + count
	}
	return result
}
